package com.hehao.java_basic.stream;


import com.hehao.common.entiy.Person;

import java.util.List;

/**
 * @author Damon
 * @date 2022/2/23
 * Foreach Find Match 方法使用介绍
 */
public class ForeachFindMatchDemo {
    public static void main(String[] args) {
        List<Person> list = Person.getList();
        //foreach
        list.stream().filter(x->x.getSalary()>8000).forEach(System.out::println);
        System.out.println("=====================");

        //find
        System.out.println(list.stream().filter(x -> x.getSalary() > 100000).findFirst().get());
        System.out.println("=====================");

        System.out.println(list.stream().filter(x -> x.getSalary() > 8000).findAny().get());
        System.out.println("=====================");

        System.out.println(list.stream().anyMatch(x -> x.getSalary() > 8000));


    }
}
